{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "92812762-e8e3-4c48-810c-d9bb6b6a5ab5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T02:19:04.580458Z",
     "iopub.status.busy": "2022-05-14T02:19:04.580042Z",
     "iopub.status.idle": "2022-05-14T02:19:04.584224Z",
     "shell.execute_reply": "2022-05-14T02:19:04.583541Z",
     "shell.execute_reply.started": "2022-05-14T02:19:04.580433Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# 导入包\n",
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a3011ea-7b0f-4d49-b018-fbf1d617f57b",
   "metadata": {
    "toc-hr-collapsed": true
   },
   "source": [
    "## 一、读数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "325a2620-04c5-450e-b146-d454eb95f42e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T02:16:12.849636Z",
     "iopub.status.busy": "2022-05-14T02:16:12.849257Z",
     "iopub.status.idle": "2022-05-14T02:16:12.867883Z",
     "shell.execute_reply": "2022-05-14T02:16:12.866947Z",
     "shell.execute_reply.started": "2022-05-14T02:16:12.849611Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "      <th>message</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>hello</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "      <td>world</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>python</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   a   b   c   d message\n",
       "0  1   2   3   4   hello\n",
       "1  5   6   7   8   world\n",
       "2  9  10  11  12  python"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice1.csv，使用默认分隔符\n",
    "df = pd.read_csv(\"data/practice1.csv\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6f3735a6-3f29-4231-8b9d-55bc252eda97",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T02:28:54.993979Z",
     "iopub.status.busy": "2022-05-14T02:28:54.993656Z",
     "iopub.status.idle": "2022-05-14T02:28:55.003709Z",
     "shell.execute_reply": "2022-05-14T02:28:55.002895Z",
     "shell.execute_reply.started": "2022-05-14T02:28:54.993955Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a,b,c,d,message</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1,2,3,4,hello</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5,6,7,8,world</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9,10,11,12,python</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     a,b,c,d,message\n",
       "0      1,2,3,4,hello\n",
       "1      5,6,7,8,world\n",
       "2  9,10,11,12,python"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice1.csv，使用默认分隔符\n",
    "df = pd.read_table(\"data/practice1.csv\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5d81a68b-36f9-477f-8c22-d705bb1d79ce",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T02:47:10.934491Z",
     "iopub.status.busy": "2022-05-14T02:47:10.934048Z",
     "iopub.status.idle": "2022-05-14T02:47:10.945524Z",
     "shell.execute_reply": "2022-05-14T02:47:10.944635Z",
     "shell.execute_reply.started": "2022-05-14T02:47:10.934468Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "      <th>message</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>hello</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "      <td>world</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>python</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   a   b   c   d message\n",
       "0  1   2   3   4   hello\n",
       "1  5   6   7   8   world\n",
       "2  9  10  11  12  python"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice1.csv，手动指定分隔符\n",
    "df = pd.read_table(\"data/practice1.csv\", sep=\",\")  # delimiter=\",\"也可以\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "023741fc-7813-4a49-aedc-ff8521827195",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T02:57:44.169650Z",
     "iopub.status.busy": "2022-05-14T02:57:44.169206Z",
     "iopub.status.idle": "2022-05-14T02:57:44.180681Z",
     "shell.execute_reply": "2022-05-14T02:57:44.179835Z",
     "shell.execute_reply.started": "2022-05-14T02:57:44.169621Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>hello</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "      <td>world</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>python</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   1   2   3   4   hello\n",
       "0  5   6   7   8   world\n",
       "1  9  10  11  12  python"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice2.csv ,使用默认分隔符\n",
    "df = pd.read_csv(\"data/practice2.csv\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "46219cd7-ed2f-4c4c-9a2a-2096ba6065ca",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T03:07:04.701095Z",
     "iopub.status.busy": "2022-05-14T03:07:04.700768Z",
     "iopub.status.idle": "2022-05-14T03:07:04.712508Z",
     "shell.execute_reply": "2022-05-14T03:07:04.711798Z",
     "shell.execute_reply.started": "2022-05-14T03:07:04.701070Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>hello</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "      <td>world</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>python</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   0   1   2   3       4\n",
       "0  1   2   3   4   hello\n",
       "1  5   6   7   8   world\n",
       "2  9  10  11  12  python"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice2.csv ,设定列标签为空\n",
    "df = pd.read_csv(\"data/practice2.csv\", header=None)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "354a7eb3-f4c2-4583-8e05-5a21dc549f8f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T03:14:29.583680Z",
     "iopub.status.busy": "2022-05-14T03:14:29.583240Z",
     "iopub.status.idle": "2022-05-14T03:14:29.624768Z",
     "shell.execute_reply": "2022-05-14T03:14:29.623833Z",
     "shell.execute_reply.started": "2022-05-14T03:14:29.583654Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>hello</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "      <td>world</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>python</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   a   b   c   d       e\n",
       "0  1   2   3   4   hello\n",
       "1  5   6   7   8   world\n",
       "2  9  10  11  12  python"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice2.csv ,手动指定列标签\n",
    "df = pd.read_csv(\"data/practice2.csv\", names=[\"a\", \"b\", \"c\", \"d\", \"e\"])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f05729bb-81d8-4ed0-ac5f-7cec73b6641c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T03:21:02.097223Z",
     "iopub.status.busy": "2022-05-14T03:21:02.096894Z",
     "iopub.status.idle": "2022-05-14T03:21:02.108393Z",
     "shell.execute_reply": "2022-05-14T03:21:02.107381Z",
     "shell.execute_reply.started": "2022-05-14T03:21:02.097199Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>hello</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>world</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>python</th>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        a   b   c   d\n",
       "e                    \n",
       "hello   1   2   3   4\n",
       "world   5   6   7   8\n",
       "python  9  10  11  12"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice2.csv ,手动指定列标签\n",
    "df = pd.read_csv(\"data/practice2.csv\", names=[\"a\", \"b\", \"c\", \"d\", \"e\"], index_col=\"e\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "61885569-7e36-4c95-a96c-68eb0ea52192",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T03:34:59.025135Z",
     "iopub.status.busy": "2022-05-14T03:34:59.024808Z",
     "iopub.status.idle": "2022-05-14T03:34:59.036464Z",
     "shell.execute_reply": "2022-05-14T03:34:59.035435Z",
     "shell.execute_reply.started": "2022-05-14T03:34:59.025111Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>value1</th>\n",
       "      <th>value2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>one</td>\n",
       "      <td>a</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>one</td>\n",
       "      <td>b</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>one</td>\n",
       "      <td>c</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>one</td>\n",
       "      <td>d</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>two</td>\n",
       "      <td>a</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>two</td>\n",
       "      <td>b</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>two</td>\n",
       "      <td>c</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>two</td>\n",
       "      <td>d</td>\n",
       "      <td>15</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2  value1  value2\n",
       "0  one    a       1       2\n",
       "1  one    b       3       4\n",
       "2  one    c       5       6\n",
       "3  one    d       7       8\n",
       "4  two    a       9      10\n",
       "5  two    b      11      12\n",
       "6  two    c      13      14\n",
       "7  two    d      15      16"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice3.csv\n",
    "df = pd.read_csv(\"data/practice3.csv\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "c80efee1-dee9-4107-93f7-47c1ade4b627",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T03:40:20.508731Z",
     "iopub.status.busy": "2022-05-14T03:40:20.508412Z",
     "iopub.status.idle": "2022-05-14T03:40:20.521874Z",
     "shell.execute_reply": "2022-05-14T03:40:20.521137Z",
     "shell.execute_reply.started": "2022-05-14T03:40:20.508709Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>value1</th>\n",
       "      <th>value2</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"4\" valign=\"top\">one</th>\n",
       "      <th>a</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"4\" valign=\"top\">two</th>\n",
       "      <th>a</th>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>15</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           value1  value2\n",
       "key1 key2                \n",
       "one  a          1       2\n",
       "     b          3       4\n",
       "     c          5       6\n",
       "     d          7       8\n",
       "two  a          9      10\n",
       "     b         11      12\n",
       "     c         13      14\n",
       "     d         15      16"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice3.csv，构建层次索引\n",
    "df = pd.read_csv(\"data/practice3.csv\", index_col=[\"key1\", \"key2\"])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "e34a1111-cc7f-469e-af80-6c517334de01",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T04:01:08.624154Z",
     "iopub.status.busy": "2022-05-14T04:01:08.623840Z",
     "iopub.status.idle": "2022-05-14T04:01:08.633384Z",
     "shell.execute_reply": "2022-05-14T04:01:08.632475Z",
     "shell.execute_reply.started": "2022-05-14T04:01:08.624130Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A         B         C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>aaa -0.264438 -1.026059 -0.619500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>bbb  0.927272  0.302904 -0.032399</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ccc -0.264273 -0.386314 -0.217601</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ddd -0.871858 -0.348382  1.100491</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               A         B         C\n",
       "0  aaa -0.264438 -1.026059 -0.619500\n",
       "1  bbb  0.927272  0.302904 -0.032399\n",
       "2  ccc -0.264273 -0.386314 -0.217601\n",
       "3  ddd -0.871858 -0.348382  1.100491"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 尝试读取practice4.txt\n",
    "pd.read_csv(\"data/practice4.txt\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "d3866028-2b4e-4bfb-8ffa-6cbdfb731b0d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T04:00:14.745312Z",
     "iopub.status.busy": "2022-05-14T04:00:14.744939Z",
     "iopub.status.idle": "2022-05-14T04:00:14.755535Z",
     "shell.execute_reply": "2022-05-14T04:00:14.754874Z",
     "shell.execute_reply.started": "2022-05-14T04:00:14.745287Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>aaa</th>\n",
       "      <td>-0.264438</td>\n",
       "      <td>-1.026059</td>\n",
       "      <td>-0.619500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>bbb</th>\n",
       "      <td>0.927272</td>\n",
       "      <td>0.302904</td>\n",
       "      <td>-0.032399</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ccc</th>\n",
       "      <td>-0.264273</td>\n",
       "      <td>-0.386314</td>\n",
       "      <td>-0.217601</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ddd</th>\n",
       "      <td>-0.871858</td>\n",
       "      <td>-0.348382</td>\n",
       "      <td>1.100491</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            A         B         C\n",
       "aaa -0.264438 -1.026059 -0.619500\n",
       "bbb  0.927272  0.302904 -0.032399\n",
       "ccc -0.264273 -0.386314 -0.217601\n",
       "ddd -0.871858 -0.348382  1.100491"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice4.txt，设置分隔符\n",
    "pd.read_csv(\"data/practice4.txt\", sep=\"\\s+\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef24209c-9c99-4eca-9f66-671fdaf32ba7",
   "metadata": {},
   "source": [
    "## 二、写数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "860b88f8-7d9c-4f74-8ce9-6a60367a6bb0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T07:08:51.361961Z",
     "iopub.status.busy": "2022-05-14T07:08:51.361622Z",
     "iopub.status.idle": "2022-05-14T07:08:51.371531Z",
     "shell.execute_reply": "2022-05-14T07:08:51.370735Z",
     "shell.execute_reply.started": "2022-05-14T07:08:51.361935Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "      <th>message</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>hello</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "      <td>world</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>python</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   a   b   c   d message\n",
       "0  1   2   3   4   hello\n",
       "1  5   6   7   8   world\n",
       "2  9  10  11  12  python"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取practice1.csv ,使用默认分隔符\n",
    "df = pd.read_csv(\"data/practice1.csv\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "b81d9368-c514-4c36-b6c0-f60a43338939",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T07:13:08.323334Z",
     "iopub.status.busy": "2022-05-14T07:13:08.322924Z",
     "iopub.status.idle": "2022-05-14T07:13:08.330577Z",
     "shell.execute_reply": "2022-05-14T07:13:08.329406Z",
     "shell.execute_reply.started": "2022-05-14T07:13:08.323305Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# 把df写到csv文件中\n",
    "df.to_csv(\"data/practice1_out.csv\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0cd3d5d4-2666-4ffb-a160-0bb2446e8c8b",
   "metadata": {
    "tags": []
   },
   "source": [
    "## 三、分块读取大文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "07ff1598-949f-4461-92d7-a16403129f22",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 直接读取大文件？别作死\n",
    "df1 = pd.read_csv(\"data/practice5.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "85886694-9833-4b8e-920c-ad2dd569384a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T08:52:16.717876Z",
     "iopub.status.busy": "2022-05-14T08:52:16.717548Z",
     "iopub.status.idle": "2022-05-14T08:52:16.724647Z",
     "shell.execute_reply": "2022-05-14T08:52:16.723668Z",
     "shell.execute_reply.started": "2022-05-14T08:52:16.717851Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pandas.io.parsers.readers.TextFileReader at 0x1146ff310>"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分块读取大文件\n",
    "chunks = pd.read_csv(\"data/practice5.csv\", chunksize=10)\n",
    "chunks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "64b2fb7c-0e99-4652-84b7-1ee9f2e52903",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T09:06:27.792572Z",
     "iopub.status.busy": "2022-05-14T09:06:27.792255Z",
     "iopub.status.idle": "2022-05-14T09:06:27.812453Z",
     "shell.execute_reply": "2022-05-14T09:06:27.811817Z",
     "shell.execute_reply.started": "2022-05-14T09:06:27.792548Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>game_size</th>\n",
       "      <th>match_id</th>\n",
       "      <th>match_mode</th>\n",
       "      <th>party_size</th>\n",
       "      <th>player_assists</th>\n",
       "      <th>player_dbno</th>\n",
       "      <th>player_dist_ride</th>\n",
       "      <th>player_dist_walk</th>\n",
       "      <th>player_dmg</th>\n",
       "      <th>player_kills</th>\n",
       "      <th>player_name</th>\n",
       "      <th>player_survive_time</th>\n",
       "      <th>team_id</th>\n",
       "      <th>team_placement</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>324.223541</td>\n",
       "      <td>49</td>\n",
       "      <td>0</td>\n",
       "      <td>oilfieldgamer</td>\n",
       "      <td>173.191</td>\n",
       "      <td>100063</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>469.269775</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>PIAOREN</td>\n",
       "      <td>355.758</td>\n",
       "      <td>100066</td>\n",
       "      <td>66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>32.353622</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Alxfrank21</td>\n",
       "      <td>109.212</td>\n",
       "      <td>100071</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>604.5532</td>\n",
       "      <td>1693.617310</td>\n",
       "      <td>127</td>\n",
       "      <td>1</td>\n",
       "      <td>ShelbyMedic</td>\n",
       "      <td>1448.822</td>\n",
       "      <td>100073</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>1719.786130</td>\n",
       "      <td>124</td>\n",
       "      <td>2</td>\n",
       "      <td>Richi10</td>\n",
       "      <td>1023.009</td>\n",
       "      <td>100079</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>1606.858640</td>\n",
       "      <td>156</td>\n",
       "      <td>2</td>\n",
       "      <td>HAIRONFIRE</td>\n",
       "      <td>708.762</td>\n",
       "      <td>100081</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>3384.201000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Lustformuffins</td>\n",
       "      <td>1412.209</td>\n",
       "      <td>100087</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>601.517800</td>\n",
       "      <td>99</td>\n",
       "      <td>1</td>\n",
       "      <td>YallMadBro</td>\n",
       "      <td>1145.901</td>\n",
       "      <td>100089</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>404.608800</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>in4red</td>\n",
       "      <td>396.464</td>\n",
       "      <td>100091</td>\n",
       "      <td>63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>296.235840</td>\n",
       "      <td>98</td>\n",
       "      <td>0</td>\n",
       "      <td>BunnyJosephine</td>\n",
       "      <td>198.648</td>\n",
       "      <td>100092</td>\n",
       "      <td>79</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        date  game_size  \\\n",
       "20  2017-11-26T01:47:01+0000         97   \n",
       "21  2017-11-26T01:47:01+0000         97   \n",
       "22  2017-11-26T01:47:01+0000         97   \n",
       "23  2017-11-26T01:47:01+0000         97   \n",
       "24  2017-11-26T01:47:01+0000         97   \n",
       "25  2017-11-26T01:47:01+0000         97   \n",
       "26  2017-11-26T01:47:01+0000         97   \n",
       "27  2017-11-26T01:47:01+0000         97   \n",
       "28  2017-11-26T01:47:01+0000         97   \n",
       "29  2017-11-26T01:47:01+0000         97   \n",
       "\n",
       "                                             match_id match_mode  party_size  \\\n",
       "20  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "21  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "22  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "23  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "24  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "25  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "26  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "27  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "28  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "29  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "\n",
       "    player_assists  player_dbno  player_dist_ride  player_dist_walk  \\\n",
       "20               0            0            0.0000        324.223541   \n",
       "21               0            0            0.0000        469.269775   \n",
       "22               0            0            0.0000         32.353622   \n",
       "23               0            0          604.5532       1693.617310   \n",
       "24               0            0            0.0000       1719.786130   \n",
       "25               0            0            0.0000       1606.858640   \n",
       "26               0            0            0.0000       3384.201000   \n",
       "27               0            0            0.0000        601.517800   \n",
       "28               0            0            0.0000        404.608800   \n",
       "29               0            0            0.0000        296.235840   \n",
       "\n",
       "    player_dmg  player_kills     player_name  player_survive_time  team_id  \\\n",
       "20          49             0   oilfieldgamer              173.191   100063   \n",
       "21           0             0         PIAOREN              355.758   100066   \n",
       "22           0             0      Alxfrank21              109.212   100071   \n",
       "23         127             1     ShelbyMedic             1448.822   100073   \n",
       "24         124             2         Richi10             1023.009   100079   \n",
       "25         156             2      HAIRONFIRE              708.762   100081   \n",
       "26           0             0  Lustformuffins             1412.209   100087   \n",
       "27          99             1      YallMadBro             1145.901   100089   \n",
       "28           0             0          in4red              396.464   100091   \n",
       "29          98             0  BunnyJosephine              198.648   100092   \n",
       "\n",
       "    team_placement  \n",
       "20              82  \n",
       "21              66  \n",
       "22              93  \n",
       "23              12  \n",
       "24              36  \n",
       "25              48  \n",
       "26              15  \n",
       "27              62  \n",
       "28              63  \n",
       "29              79  "
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取当前chunk的数据\n",
    "chunks.get_chunk()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "d3ac1c0b-a990-48a4-bbf1-11199553e8a9",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T09:13:14.709384Z",
     "iopub.status.busy": "2022-05-14T09:13:14.709065Z",
     "iopub.status.idle": "2022-05-14T09:13:14.728605Z",
     "shell.execute_reply": "2022-05-14T09:13:14.727645Z",
     "shell.execute_reply.started": "2022-05-14T09:13:14.709360Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>game_size</th>\n",
       "      <th>match_id</th>\n",
       "      <th>match_mode</th>\n",
       "      <th>party_size</th>\n",
       "      <th>player_assists</th>\n",
       "      <th>player_dbno</th>\n",
       "      <th>player_dist_ride</th>\n",
       "      <th>player_dist_walk</th>\n",
       "      <th>player_dmg</th>\n",
       "      <th>player_kills</th>\n",
       "      <th>player_name</th>\n",
       "      <th>player_survive_time</th>\n",
       "      <th>team_id</th>\n",
       "      <th>team_placement</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1865.1875</td>\n",
       "      <td>1998.47388</td>\n",
       "      <td>330</td>\n",
       "      <td>3</td>\n",
       "      <td>Bostonwuyanzu</td>\n",
       "      <td>1624.646</td>\n",
       "      <td>100096</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>920.0372</td>\n",
       "      <td>2439.89819</td>\n",
       "      <td>75</td>\n",
       "      <td>1</td>\n",
       "      <td>Hughe_G_Rexshin</td>\n",
       "      <td>1537.980</td>\n",
       "      <td>100017</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>2051.30957</td>\n",
       "      <td>174</td>\n",
       "      <td>1</td>\n",
       "      <td>sweet2thMuNch</td>\n",
       "      <td>1516.585</td>\n",
       "      <td>100025</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>2504.40454</td>\n",
       "      <td>168</td>\n",
       "      <td>1</td>\n",
       "      <td>Capanga09</td>\n",
       "      <td>1220.594</td>\n",
       "      <td>100027</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>84.11823</td>\n",
       "      <td>207</td>\n",
       "      <td>2</td>\n",
       "      <td>SgtTodd</td>\n",
       "      <td>260.470</td>\n",
       "      <td>100030</td>\n",
       "      <td>69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>525.4947</td>\n",
       "      <td>987.12480</td>\n",
       "      <td>357</td>\n",
       "      <td>3</td>\n",
       "      <td>flexistential</td>\n",
       "      <td>798.971</td>\n",
       "      <td>100033</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        date  game_size  \\\n",
       "30  2017-11-26T01:47:01+0000         97   \n",
       "31  2017-11-26T01:47:01+0000         97   \n",
       "32  2017-11-26T01:47:01+0000         97   \n",
       "33  2017-11-26T01:47:01+0000         97   \n",
       "34  2017-11-26T01:47:01+0000         97   \n",
       "35  2017-11-26T01:47:01+0000         97   \n",
       "\n",
       "                                             match_id match_mode  party_size  \\\n",
       "30  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "31  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "32  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "33  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "34  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "35  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "\n",
       "    player_assists  player_dbno  player_dist_ride  player_dist_walk  \\\n",
       "30               0            0         1865.1875        1998.47388   \n",
       "31               0            0          920.0372        2439.89819   \n",
       "32               0            0            0.0000        2051.30957   \n",
       "33               0            0            0.0000        2504.40454   \n",
       "34               0            0            0.0000          84.11823   \n",
       "35               0            0          525.4947         987.12480   \n",
       "\n",
       "    player_dmg  player_kills      player_name  player_survive_time  team_id  \\\n",
       "30         330             3    Bostonwuyanzu             1624.646   100096   \n",
       "31          75             1  Hughe_G_Rexshin             1537.980   100017   \n",
       "32         174             1    sweet2thMuNch             1516.585   100025   \n",
       "33         168             1        Capanga09             1220.594   100027   \n",
       "34         207             2          SgtTodd              260.470   100030   \n",
       "35         357             3    flexistential              798.971   100033   \n",
       "\n",
       "    team_placement  \n",
       "30               8  \n",
       "31              10  \n",
       "32              11  \n",
       "33              25  \n",
       "34              69  \n",
       "35              44  "
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取当前chunk的数据，临时指定size\n",
    "chunks.get_chunk(6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "bebed116-22c9-4ef1-aef0-db5edae072b7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T09:16:00.871098Z",
     "iopub.status.busy": "2022-05-14T09:16:00.870699Z",
     "iopub.status.idle": "2022-05-14T09:16:00.890694Z",
     "shell.execute_reply": "2022-05-14T09:16:00.889931Z",
     "shell.execute_reply.started": "2022-05-14T09:16:00.871074Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>game_size</th>\n",
       "      <th>match_id</th>\n",
       "      <th>match_mode</th>\n",
       "      <th>party_size</th>\n",
       "      <th>player_assists</th>\n",
       "      <th>player_dbno</th>\n",
       "      <th>player_dist_ride</th>\n",
       "      <th>player_dist_walk</th>\n",
       "      <th>player_dmg</th>\n",
       "      <th>player_kills</th>\n",
       "      <th>player_name</th>\n",
       "      <th>player_survive_time</th>\n",
       "      <th>team_id</th>\n",
       "      <th>team_placement</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1021.845520</td>\n",
       "      <td>38</td>\n",
       "      <td>0</td>\n",
       "      <td>Mmartini</td>\n",
       "      <td>554.170</td>\n",
       "      <td>100039</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>50.232723</td>\n",
       "      <td>54</td>\n",
       "      <td>0</td>\n",
       "      <td>FarNotFar</td>\n",
       "      <td>122.793</td>\n",
       "      <td>100045</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>524.243100</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>PurplePPLEater</td>\n",
       "      <td>200.669</td>\n",
       "      <td>100048</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>51.968273</td>\n",
       "      <td>49</td>\n",
       "      <td>0</td>\n",
       "      <td>cftroop</td>\n",
       "      <td>200.197</td>\n",
       "      <td>100053</td>\n",
       "      <td>78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1031.720340</td>\n",
       "      <td>100</td>\n",
       "      <td>0</td>\n",
       "      <td>DionysusPi</td>\n",
       "      <td>590.883</td>\n",
       "      <td>100058</td>\n",
       "      <td>54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>13.387692</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>Thculture</td>\n",
       "      <td>87.649</td>\n",
       "      <td>100068</td>\n",
       "      <td>96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>165.954500</td>\n",
       "      <td>13</td>\n",
       "      <td>0</td>\n",
       "      <td>Ric0_Ric0</td>\n",
       "      <td>223.821</td>\n",
       "      <td>100074</td>\n",
       "      <td>71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>30.239336</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Aswego</td>\n",
       "      <td>128.933</td>\n",
       "      <td>100075</td>\n",
       "      <td>86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>16.980430</td>\n",
       "      <td>25</td>\n",
       "      <td>0</td>\n",
       "      <td>YHSSWAG</td>\n",
       "      <td>165.120</td>\n",
       "      <td>100085</td>\n",
       "      <td>83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>218.751678</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Myster0246</td>\n",
       "      <td>234.738</td>\n",
       "      <td>100090</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        date  game_size  \\\n",
       "36  2017-11-26T01:47:01+0000         97   \n",
       "37  2017-11-26T01:47:01+0000         97   \n",
       "38  2017-11-26T01:47:01+0000         97   \n",
       "39  2017-11-26T01:47:01+0000         97   \n",
       "40  2017-11-26T01:47:01+0000         97   \n",
       "41  2017-11-26T01:47:01+0000         97   \n",
       "42  2017-11-26T01:47:01+0000         97   \n",
       "43  2017-11-26T01:47:01+0000         97   \n",
       "44  2017-11-26T01:47:01+0000         97   \n",
       "45  2017-11-26T01:47:01+0000         97   \n",
       "\n",
       "                                             match_id match_mode  party_size  \\\n",
       "36  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "37  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "38  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "39  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "40  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "41  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "42  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "43  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "44  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "45  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "\n",
       "    player_assists  player_dbno  player_dist_ride  player_dist_walk  \\\n",
       "36               0            0               0.0       1021.845520   \n",
       "37               0            0               0.0         50.232723   \n",
       "38               0            0               0.0        524.243100   \n",
       "39               0            0               0.0         51.968273   \n",
       "40               0            0               0.0       1031.720340   \n",
       "41               0            0               0.0         13.387692   \n",
       "42               0            0               0.0        165.954500   \n",
       "43               0            0               0.0         30.239336   \n",
       "44               0            0               0.0         16.980430   \n",
       "45               0            0               0.0        218.751678   \n",
       "\n",
       "    player_dmg  player_kills     player_name  player_survive_time  team_id  \\\n",
       "36          38             0        Mmartini              554.170   100039   \n",
       "37          54             0       FarNotFar              122.793   100045   \n",
       "38           0             0  PurplePPLEater              200.669   100048   \n",
       "39          49             0         cftroop              200.197   100053   \n",
       "40         100             0      DionysusPi              590.883   100058   \n",
       "41          78             0       Thculture               87.649   100068   \n",
       "42          13             0       Ric0_Ric0              223.821   100074   \n",
       "43           0             0          Aswego              128.933   100075   \n",
       "44          25             0         YHSSWAG              165.120   100085   \n",
       "45           0             0      Myster0246              234.738   100090   \n",
       "\n",
       "    team_placement  \n",
       "36              55  \n",
       "37              88  \n",
       "38              77  \n",
       "39              78  \n",
       "40              54  \n",
       "41              96  \n",
       "42              71  \n",
       "43              86  \n",
       "44              83  \n",
       "45              70  "
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取当前chunk的数据\n",
    "chunks.get_chunk()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "13a97a3f-215e-4530-bfc7-7f6f03be6f9c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T12:18:36.412401Z",
     "iopub.status.busy": "2022-05-14T12:18:36.411966Z",
     "iopub.status.idle": "2022-05-14T12:18:36.419418Z",
     "shell.execute_reply": "2022-05-14T12:18:36.418694Z",
     "shell.execute_reply.started": "2022-05-14T12:18:36.412368Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pandas.io.parsers.readers.TextFileReader at 0x18349a5c0>"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 迭代器读取大文件\n",
    "iterator = pd.read_csv(\"data/practice5.csv\", iterator=True)\n",
    "iterator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "b9924973-315f-42df-9654-177105f05a57",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T12:18:39.581965Z",
     "iopub.status.busy": "2022-05-14T12:18:39.581630Z",
     "iopub.status.idle": "2022-05-14T12:18:39.602119Z",
     "shell.execute_reply": "2022-05-14T12:18:39.601379Z",
     "shell.execute_reply.started": "2022-05-14T12:18:39.581940Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>game_size</th>\n",
       "      <th>match_id</th>\n",
       "      <th>match_mode</th>\n",
       "      <th>party_size</th>\n",
       "      <th>player_assists</th>\n",
       "      <th>player_dbno</th>\n",
       "      <th>player_dist_ride</th>\n",
       "      <th>player_dist_walk</th>\n",
       "      <th>player_dmg</th>\n",
       "      <th>player_kills</th>\n",
       "      <th>player_name</th>\n",
       "      <th>player_survive_time</th>\n",
       "      <th>team_id</th>\n",
       "      <th>team_placement</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>2082.823000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>fuckeddup</td>\n",
       "      <td>661.491</td>\n",
       "      <td>100001</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>1118.815000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>nojiongegg</td>\n",
       "      <td>741.359</td>\n",
       "      <td>100002</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>25.533026</td>\n",
       "      <td>73</td>\n",
       "      <td>0</td>\n",
       "      <td>Darthmoca</td>\n",
       "      <td>83.255</td>\n",
       "      <td>100006</td>\n",
       "      <td>97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>997.51000</td>\n",
       "      <td>1032.667850</td>\n",
       "      <td>345</td>\n",
       "      <td>3</td>\n",
       "      <td>gk1715</td>\n",
       "      <td>1144.816</td>\n",
       "      <td>100007</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2017-11-26T01:47:01+0000</td>\n",
       "      <td>97</td>\n",
       "      <td>2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...</td>\n",
       "      <td>tpp</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4296.35938</td>\n",
       "      <td>2300.323490</td>\n",
       "      <td>449</td>\n",
       "      <td>4</td>\n",
       "      <td>Angeliaboby</td>\n",
       "      <td>1112.843</td>\n",
       "      <td>100021</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       date  game_size  \\\n",
       "0  2017-11-26T01:47:01+0000         97   \n",
       "1  2017-11-26T01:47:01+0000         97   \n",
       "2  2017-11-26T01:47:01+0000         97   \n",
       "3  2017-11-26T01:47:01+0000         97   \n",
       "4  2017-11-26T01:47:01+0000         97   \n",
       "\n",
       "                                            match_id match_mode  party_size  \\\n",
       "0  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "1  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "2  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "3  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "4  2U4GBNA0Yml_MDIpsXDjMltu0-r8UqS8skCECcelwiP7iu...        tpp           1   \n",
       "\n",
       "   player_assists  player_dbno  player_dist_ride  player_dist_walk  \\\n",
       "0               0            0           0.00000       2082.823000   \n",
       "1               0            0           0.00000       1118.815000   \n",
       "2               0            0           0.00000         25.533026   \n",
       "3               0            0         997.51000       1032.667850   \n",
       "4               0            0        4296.35938       2300.323490   \n",
       "\n",
       "   player_dmg  player_kills  player_name  player_survive_time  team_id  \\\n",
       "0           0             0    fuckeddup              661.491   100001   \n",
       "1           0             0   nojiongegg              741.359   100002   \n",
       "2          73             0    Darthmoca               83.255   100006   \n",
       "3         345             3       gk1715             1144.816   100007   \n",
       "4         449             4  Angeliaboby             1112.843   100021   \n",
       "\n",
       "   team_placement  \n",
       "0              50  \n",
       "1              47  \n",
       "2              97  \n",
       "3              30  \n",
       "4              32  "
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "iterator.get_chunk(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ce93136a-adc7-4a4d-abcc-3611822c4287",
   "metadata": {
    "jupyter": {
     "source_hidden": true
    },
    "tags": []
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "3e6dc99a-ab8f-40ba-ba5c-39d5ec20eb4e",
   "metadata": {},
   "source": [
    "## 四、JSON"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "497a9df6-cb1c-46bc-80f9-0a81b4a748ee",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T07:47:52.551165Z",
     "iopub.status.busy": "2022-05-14T07:47:52.550844Z",
     "iopub.status.idle": "2022-05-14T07:47:52.555339Z",
     "shell.execute_reply": "2022-05-14T07:47:52.554197Z",
     "shell.execute_reply.started": "2022-05-14T07:47:52.551139Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "obj = \"\"\"{\"msg\":\"ok\",\n",
    "    \"location\":{\n",
    "        \"level\":\"地名地址\",\n",
    "        \"lon\":116.40100299989,\n",
    "        \"lat\":39.90311700025,\n",
    "        \"keyWord\":\"北京市\"\n",
    "    },\n",
    "    \"searchVersion\":\"6.0.0\",\n",
    "    \"status\":\"0\"}\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "bc2635fd-0f87-498c-a9b5-ae9380c3d7cf",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T07:51:36.722984Z",
     "iopub.status.busy": "2022-05-14T07:51:36.722667Z",
     "iopub.status.idle": "2022-05-14T07:51:36.727928Z",
     "shell.execute_reply": "2022-05-14T07:51:36.727145Z",
     "shell.execute_reply.started": "2022-05-14T07:51:36.722961Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'{\"msg\":\"ok\",\\n    \"location\":{\\n        \"level\":\"地名地址\",\\n        \"lon\":116.40100299989,\\n        \"lat\":39.90311700025,\\n        \"keyWord\":\"北京市\"\\n    },\\n    \"searchVersion\":\"6.0.0\",\\n    \"status\":\"0\"}'"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "7edccc6e-6bd3-4e3b-9ae3-e096420e9bf4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T08:03:13.261039Z",
     "iopub.status.busy": "2022-05-14T08:03:13.260724Z",
     "iopub.status.idle": "2022-05-14T08:03:13.267293Z",
     "shell.execute_reply": "2022-05-14T08:03:13.266417Z",
     "shell.execute_reply.started": "2022-05-14T08:03:13.261015Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'msg': 'ok',\n",
       " 'location': {'level': '地名地址',\n",
       "  'lon': 116.40100299989,\n",
       "  'lat': 39.90311700025,\n",
       "  'keyWord': '北京市'},\n",
       " 'searchVersion': '6.0.0',\n",
       " 'status': '0'}"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import json\n",
    "\n",
    "# 把json字符串转换为dict\n",
    "res = json.loads(obj)\n",
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "c49b2e74-a095-4c4d-82d5-0c3bcac6fb3d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-14T08:09:03.556198Z",
     "iopub.status.busy": "2022-05-14T08:09:03.555876Z",
     "iopub.status.idle": "2022-05-14T08:09:03.561973Z",
     "shell.execute_reply": "2022-05-14T08:09:03.561328Z",
     "shell.execute_reply.started": "2022-05-14T08:09:03.556171Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'{\"msg\": \"ok\", \"location\": {\"level\": \"\\\\u5730\\\\u540d\\\\u5730\\\\u5740\", \"lon\": 116.40100299989, \"lat\": 39.90311700025, \"keyWord\": \"\\\\u5317\\\\u4eac\\\\u5e02\"}, \"searchVersion\": \"6.0.0\", \"status\": \"0\"}'"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 把dict对象转换成json字符串\n",
    "json1 = json.dumps(res)\n",
    "json1"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
